<template>
  <div v-if="repoList[repoIndex]">
    <el-checkbox
      v-for="component in repoList[repoIndex].componentList"
      :key="projList[projIndex].projName + repoList[repoIndex].libName + component"
      class="component-checkbox"
      :class="{'color-blue': projList[projIndex].libList[repoIndex] && projList[projIndex].libList[repoIndex].dependencyList.includes(component)}"
      :value="projList[projIndex].libList[repoIndex] && projList[projIndex].libList[repoIndex].selectionList.includes(component)"
      @change="onChange($event, component)"
    >{{ component }}</el-checkbox>
  </div>
</template>

<script>
export default {
  props: {
    projList: {
      type: Array,
    },
    repoList: {
      type: Array,
    },
    projIndex: {
      type: Number,
      default: 0,
    },
    repoIndex: {
      type: Number,
      default: 0,
    },
  },
  methods: {
    onChange(value, component) {
      this.$emit('changeCheckbox', { component, value });
    },
  },
};
</script>

<style lang="scss">
.component-checkbox {
  width: 150px;
  margin-top: 10px;
  margin-bottom: 10px;
  &.color-blue {
    color: #409eff;
  }
}
</style>
